<template>
	<div class="bd">
		<p>computed:</p>
		<p>{{ count }}</p>
		<p>{{ plusOne }}</p>
		<button @click="change">切换</button>
	</div>
</template>

<script setup lang="ts">
import { ref, computed, toValue } from 'vue'

const count = ref(1)
const plusOne = computed({
	get() {
		return count.value + 1
	},
	set(val) {
		count.value = val - 1
	},
})
const change = () => {
	count.value += 1
	// 返回原始值
	console.log(toValue(() => count.value))
}
// TODO 这里赋值后，plusOne已经是赋值后的数据，所以在set中的val一斤是改变后的值
plusOne.value += 3
</script>
